﻿<?php 
	include "mysql.class.php";
	$db = new DB();
	$db->connect("localhost", "root", "", "vgou3.0s", $pconnect = 0,$charset='utf8');
	$imei = $_GET['imei'];
	//$r = $db->get_one("SELECT * FROM `vg_order_print`");
	$r = $db->get_one("SELECT * FROM `vg_order_print` where imei=".$imei);

	if(!$r){
		echo "00";
		exit();
	}
	// $a = json_encode($r);
	// $d = json_decode($a);
	// var_dump($d);
	//$a = JSON($r);
	//$a = '{"id":"0"}';
	
	
	//$b = getBytes($a);
	//var_dump($b);
	
	$content = unserialize($r["menu"]);
	$r["menu"] = $content["order"];
	$r["totalPrice"] = $content["totalPrice"];
	header('Content-type:text/json;charset=utf8'); 
	$a = JSON($r);
	echo $a;


   function getBytes($string) {  
        $bytes = array();  
        for($i = 0; $i < strlen($string); $i++){  
             $bytes[] = ord($string[$i]);  
        }  
        return $bytes;  
    }  



	function JSON($array) {
	    arrayRecursive($array, 'urlencode', true);

	    $json = json_encode($array);

	    return urldecode($json);

	}

		function arrayRecursive(&$array, $function, $apply_to_keys_also = false){

	    static $recursive_counter = 0;

	    if (++$recursive_counter > 1000) {

	        die('possible deep recursion attack');

	    }

	    foreach ($array as $key => $value) {

	        if (is_array($value)) {

	            arrayRecursive($array[$key], $function, $apply_to_keys_also);

	        } else {

	            $array[$key] = $function($value);

	        }

	  

	        if ($apply_to_keys_also && is_string($key)) {

	            $new_key = $function($key);

	            if ($new_key != $key) {

	                $array[$new_key] = $array[$key];

	                unset($array[$key]);

	            }

	        }

	    }

	    $recursive_counter--;

	}
?>